package com.me.jingdongshop.ui.activity;

import android.os.Message;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.me.common.base.BaseActivity;
import com.me.jingdongshop.R;

/**
 * Created by ldl on 2017/5/7.
 * 填写发票信息界面
 */

public class WriteInvoiceActivity extends BaseActivity {
    private TextView tvWriteInvoiceBack;     // 地址列表返回
    private TextView tvInvoiceAdd;      // 新增列表
    private TextView tvInvoiceConfirm;      // 发票信息确定
    public static final int RESULT_CODE = 04;

    private RadioGroup rgInvoiceTitle;
    private RadioGroup rgInvoiceBody;

    private RadioButton rbPersonal;
    private RadioButton rbUtil;
    private RadioButton rbBook;
    private RadioButton rbSound;
    private RadioButton rbGame;
    private RadioButton rbSoftware;
    private RadioButton rbDatum;

    private String InvoiceTitleData = "";
    private String InvoiceBodyData = "";
    public String InvoiceData = "";

    @Override
    public int getLayoutRes() {
        return R.layout.activity_shopcart_writeinvoice;
    }

    @Override
    public void initView() {
        tvWriteInvoiceBack = (TextView) findViewById(R.id.tv_writeinvoice_back);
        tvInvoiceAdd = (TextView) findViewById(R.id.tv_invoice_add);
        tvInvoiceConfirm = (TextView) findViewById(R.id.tv_invoice_confirm);

        rgInvoiceTitle = (RadioGroup) findViewById(R.id.rg_invoice_title);
        rgInvoiceBody = (RadioGroup) findViewById(R.id.rg_invoice_body);

        rbPersonal = (RadioButton) findViewById(R.id.rb_personal);
        rbUtil = (RadioButton) findViewById(R.id.rb_util);
        rbBook = (RadioButton) findViewById(R.id.rb_book);
        rbSound = (RadioButton) findViewById(R.id.rb_sound);
        rbGame = (RadioButton) findViewById(R.id.rb_game);
        rbSoftware = (RadioButton) findViewById(R.id.rb_software);
        rbDatum = (RadioButton) findViewById(R.id.rb_datum);
    }

    @Override
    public void initListener() {
        tvWriteInvoiceBack.setOnClickListener(this);
        tvInvoiceAdd.setOnClickListener(this);
        tvInvoiceConfirm.setOnClickListener(this);

        rgInvoiceTitle.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == rbPersonal.getId()) {
                    InvoiceTitleData = "个人";
                } else if (checkedId == rbUtil.getId()) {
                    InvoiceTitleData = "单位";
                }
            }
        });
        rgInvoiceBody.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == rbBook.getId()) {
                    InvoiceBodyData = "图书";
                } else if (checkedId == rbSound.getId()) {
                    InvoiceBodyData = "音像";
                } else if (checkedId == rbGame.getId()) {
                    InvoiceBodyData = "游戏";
                } else if (checkedId == rbSoftware.getId()) {
                    InvoiceBodyData = "软件";
                } else if (checkedId == rbDatum.getId()) {
                    InvoiceBodyData = "资料";
                }
            }
        });
        InvoiceData = InvoiceTitleData + "/" + InvoiceBodyData;
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View v, int id) {
        switch (id) {
            case R.id.tv_writeinvoice_back:
                finish();
                break;
            case R.id.tv_invoice_add:
                Toast.makeText(getApplicationContext(), "跳转添加发票界面", Toast.LENGTH_SHORT).show();
                break;
            case R.id.tv_invoice_confirm:
                finish();
                break;
        }
    }

    @Override
    public void onHttpSuccess(int reqType, Message msg) {

    }

    @Override
    public void onHttpError(int reqType, String error) {

    }
}
